package sz.szsmk.citizencard.mvp.presenter;

import android.util.Log;

import com.google.gson.Gson;

import javax.inject.Inject;

import sz.szsmk.citizencard.DaggerApplication;
import sz.szsmk.citizencard.log.L;
import sz.szsmk.citizencard.model.network.GsdxNetApi;
import sz.szsmk.citizencard.model.network.NetWorkUtils;
import sz.szsmk.citizencard.model.network.bean.request.QueryNearStandbyReq;
import sz.szsmk.citizencard.model.network.bean.response.QueryNearMetroStandbyRes;
import sz.szsmk.citizencard.model.network.bean.response.QueryNearStandbyRes;
import sz.szsmk.citizencard.mvp.contract.IBusSiteNearbyContact;
import sz.szsmk.citizencard.mvp.contract.ITripPlanContact;
import sz.szsmk.citizencard.retrofitrxjava.ErrorAction;
import sz.szsmk.citizencard.retrofitrxjava.NetworkDateSources;
import sz.szsmk.citizencard.retrofitrxjava.SubscribeResult;
import sz.szsmk.citizencard.smkretrofit.NetworkDateSource;
import sz.szsmk.citizencard.ui.activity.IMainActivity;
import sz.szsmk.citizencard.util.Constant;

public class ItripPlanPresenter extends IBasePresenter implements ITripPlanContact.ITripPlanPresenter<ITripPlanContact.ITripPlanView> {

    private NetworkDateSources mNetworkDateSource;
    GsdxNetApi gsdxNetApi;


    @Inject
    public ItripPlanPresenter(GsdxNetApi gsdxNetApi){
        this.gsdxNetApi=gsdxNetApi;
        this.mNetworkDateSource= NetworkDateSources.getInstance();
    }

    @Override
    public void getBusNearStation() {
        QueryNearStandbyReq queryNearStandbyReq = new QueryNearStandbyReq();
//        queryNearStandbyReq.setLatitude(s);
//        queryNearStandbyReq.setLongitude(keyword);

//        queryNearStandbyReq.setLatitude("31.259186");
//        queryNearStandbyReq.setLongitude("120.636177");
        queryNearStandbyReq.setUserID("string");
        String json = new Gson().toJson(queryNearStandbyReq);

        Log.d("clark","--------------"+json);
        mNetworkDateSource.queryNearStandby(queryNearStandbyReq, new SubscribeResult<QueryNearStandbyRes>() {
            @Override
            protected void onOk(QueryNearStandbyRes response) {
                String json = new Gson().toJson(response);
                L.e(Constant.TAG,"------------"+json);
                ((ITripPlanContact.ITripPlanView) mView).getBusNearStationSuc(response);
            }

            @Override
            protected void onFailure(QueryNearStandbyRes response) {
                super.onFailure(response);
            }
        }, new ErrorAction() {
            @Override
            public void onCall(Throwable throwable) {

            }
        });
    }

    @Override
    public void getSubwayNearStation() {
        QueryNearStandbyReq queryNearStandbyReq = new QueryNearStandbyReq();
//        queryNearStandbyReq.setLatitude(s);
//        queryNearStandbyReq.setLongitude(keyword);

//        queryNearStandbyReq.setLatitude("31.259186");
//        queryNearStandbyReq.setLongitude("120.636177");
        queryNearStandbyReq.setUserID("string");
        String json = new Gson().toJson(queryNearStandbyReq);
        mNetworkDateSource.queryNearMetroStandby(queryNearStandbyReq, new SubscribeResult<QueryNearMetroStandbyRes>() {
            @Override
            protected void onOk(QueryNearMetroStandbyRes response) {
                String json = new Gson().toJson(response);
                L.e(Constant.TAG,"------------"+json);
                ((ITripPlanContact.ITripPlanView) mView).getSubwayNearStationSuc(response);
            }

            @Override
            protected void onFailure(QueryNearMetroStandbyRes response) {
                super.onFailure(response);
            }
        }, new ErrorAction() {
            @Override
            public void onCall(Throwable throwable) {

            }
        });
    }
}
